package com.java.springcloud.alibaba.service.impl;

import com.java.springcloud.alibaba.dao.AccountDao;
import com.java.springcloud.alibaba.service.AccountService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.math.BigDecimal;

/**
 * @author jingjintao
 * @date 2021/8/20 - 23:06
 **/
@Service
@Slf4j
public class AccountServiceImpl implements AccountService {

    @Resource
    private AccountDao accountDao;

    @Override
    public void decrease(Long userId, BigDecimal money) {
        log.info("*******************account-service中扣减账户余额开始");
        accountDao.decrease(userId, money);
        //模拟超时异常
//        try {
//            Thread.sleep(20 * 1000);
//        } catch (InterruptedException e) {
//            e.printStackTrace();
//        }
        log.info("*******************account-service中扣减账户余额结束");
    }
}
